<template>
  <div class="login">
    <h2>登录</h2>
    <input type="text" placeholder="请输入用户名" />
    <input type="password" placeholder="请输入密码" />
    <button @click="hand()">登录</button>
    <router-link to="/resgiter" class="go">注册</router-link>
  </div>
</template>

<script>
import { user_login } from "../api";
export default {
  data() {
    return {
      list: [],
    };
  },
  mounted() {},
  methods: {
    hand() {
      user_login({ phone: 15291695373, pass: 1234 }).then((res) => {
        // console.log(res);
        console.log(res.data);
        // console.log(res.data.userinfo.id);
        this.list = res.data.list;
        localStorage.setItem("token", res.data.token);
        localStorage.setItem("userinfo", JSON.stringify(res.data.userinfo));
        if (res.data.code == 200) {
          // console.log('a'+this.list.userinfo.id);

          this.$router.push("/footer/mine");
        } else {
          console.log("aaa");
        }
      });
    },
  },
};
</script>

<style scoped>
.login {
  width: 100%;
  height: 100%;
}
h2 {
  height: 200px;
  line-height: 200px;
  text-align: center;
}
input {
  width: 200px;
  height: 30px;
  display: block;
  outline: none;
  border: 1px solid #ccc;
  border-radius: 10px;
  margin: 20px auto;
  padding-left: 10px;
  box-sizing: border-box;
}
button {
  width: 200px;
  height: 30px;
  display: block;
  outline: none;
  border: 1px solid #ccc;
  border-radius: 10px;
  margin: 20px auto;
  text-align: center;
}
.go {
  display: block;
  margin-left: 300px;
}
</style>